% Title

\documentclass[a4paper, 12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[english, russian]{babel}
\usepackage{amsmath, amsfonts, amssymb, amsthm}
\usepackage{tikz} % some graphics
\usepackage[indentheadings]{russcorr}
\usetikzlibrary{arrows}


\hfuzz=18pt

% Commands

\newcommand*{\hm}[1]{#1\nobreak\discretionary{}%
{\hbox{$\mathsurround=0pt #1$}}{}} % a\hm=b makes "=" carriable to the next line with duplication of the sign

\newcommand{\combus}[2]{\left(\begin{array}{c}#1 \\ #2 \end{array} \right)} % american style for C_n^k
\newcommand{\combru}[2]{C_{#1}^{#2}} % russian C_n^k
\newcommand{\comb}[2]{\combru{#1}{#2}}
\newcommand{\myN}{\mathbb{N}} % nice letters for common number sets
\newcommand{\myZ}{\mathbb{Z}}
\newcommand{\myR}{\mathbb{R}}
\newcommand{\myC}{\mathbb{C}}
\newcommand{\myQ}{\mathbb{Q}}
\newcommand{\myE}{\mathcal{E}} % basis
\newcommand{\myF}{\mathcal{F}} % one more basis
\newcommand{\mysetM}{\mathcal{M}}
\newcommand{\mysetN}{\mathcal{N}}
\newcommand{\myset}[1]{\mathcal{#1}}
\newcommand{\walls}[1]{\left | #1 \right |} % |smth_vertically_large|
\newcommand{\pars}[1]{\left( #1 \right)} % (smth_vertically_large)
\newcommand{\class}[1]{[ #1 ]} % [smth_vertically_large]
\newcommand{\bra}[1]{\langle #1 \rangle} % brackets for span of vectors, eg. <e_1, ..., e_k>
\newcommand{\myset}[1]{\left\{ #1 \right\}} % because { and } are special symbols in TeX
\newcommand{\mysetso}[2]{\myset{#1 \mid #2}} 
%
% Example text:
% M = {x^2 | x is prime}
% 
% Corresponding markup:                               
% $$ \mysetM = \mysetso{x^2}{x \text{ is prime}} $$
%
\newcommand{\myleq}{\leqslant}
\newcommand{\mygeq}{\geqslant}
\newcommand{\myempty}{\varnothing}
\newcommand{\myand}{\;\; \hm\& \;\;}				
\newcommand{\myor}{\; \hm\vee \;}					
\newcommand{\mychar}[1]{\mytext{char} #1} % characteristic of a field
\newcommand{\conj}[1]{\overline{#1}} % complex conjugation
\newcommand{\mycirc}{\circ}
\newcommand{\poly}[2]{#1 [ #2 ]} % ring of polynomials 
\newcommand{\Rx}{\poly{\myR}{x}}
\newcommand{\Cx}{\poly{\myC}{x}}
\newcommand{\mydim}[1]{\dim #1}
\newcommand{\mycodim}[1]{\mytext{codim} #1}
\newcommand{\coords}[2]{\pars{#1}_{#2}}
\newcommand{\myrank}[1]{\mytext{rank} #1}
\newcommand{\mysegment}[2]{[#1, #2]} 				
\newcommand{\myinterval}[2]{(#1, #2)} 				
\newcommand{\mypair}[2]{(#1, #2)}			
\newcommand{\myfunc}[3]{#1\!:\,#2 \hm\to #3} % TODO: make spaces between elements of this tag look better
\newcommand{\suchthat}{\!:\,}					
\newcommand{\mydef}[1]{\emph{#1}}

% Arrows
\newcommand{\myright}{\;\hm\Rightarrow\;}
\newcommand{\myleft}{\;\hm\Leftarrow\;}
\newcommand{\myleftright}{\;\hm\Leftrightarrow\;}
% \newcommand{\vect}[1]{\overrightarrow{\vphantom{b}#1}}
\newcommand{\vect}[1]{\Vec{\vphantom{b}#1}}

% Sums, prods and other things with \limits
\newcommand{\mysum}{\sum\limits}
\newcommand{\myprod}{\prod\limits}
\newcommand{\mylim}{\lim\limits}
\newcommand{\mybigcup}{\bigcup\limits}
\newcommand{\mybigcap}{\bigcap\limits}
\newcommand{\mybigor}{\bigvee\limits}
\newcommand{\mybigand}{\bigwedge\limits}

\newcommand{\smatrix}[1]{\begin{smallmatrix}#1\end{smallmatrix}}
\newcommand{\psmatrix}[1]{\pars{\begin{smallmatrix}#1\end{smallmatrix}}}
\newcommand{\wsmatrix}[1]{\walls{\begin{smallmatrix}#1\end{smallmatrix}}}

% Operators
\DeclareMathOperator{\pr}{pr} % Проекция
\DeclareMathOperator{\id}{id} % Тождественное преобразование

% Special theorems
\newtheorem*{theorem-menelaus}{Теорема Менелая}

% Theorems
\newtheorem*{theorem-star}{Теорема}
\newtheorem{theorem}{Теорема}
\newtheorem*{theorem-definition-star}{Теорема-определение}
\newtheorem*{corollary-star}{Следствие}
\newtheorem{corollary}{Следствие}
\newtheorem*{property-star}{Свойство}
\newtheorem{property}{Свойство}
\newtheorem*{lem-star}{Лемма}
\newtheorem{lem}{Лемма}
\newtheorem*{proposition-star}{Предложение}
\newtheorem{proposition}{Предложение}
\newtheorem{stage}{Этап}
\newtheorem*{statement}{Утверждение}
\newtheorem*{designation}{Обозначение}
\newtheorem*{usage}{Использование}

\theoremstyle{remark}
\newtheorem*{remark}{Замечание}

\theoremstyle{definition}
\newtheorem{problem}{Задача}
\newtheorem{exercise}{Упражнение}

\theoremstyle{definition}
\newtheorem*{definition-star}{Определение}
\newtheorem{definition}{Определение}

\theoremstyle{definition}
\newtheorem*{example-star}{Пример}
\newtheorem{example}{Пример}

% Style
\newcommand{\tocstyle}{\setlength{\parindent}{0ex} \setlength{\parskip}{0ex}}
\newcommand{\mainstyle}{\setlength{\parindent}{0ex} \setlength{\parskip}{1ex}}

\mainstyle
\setcounter{secnumdepth}{2}
\renewcommand{\thesubsection}{\arabic{subsection}}


% Titles of lectures
\newcommand{\mylecture}[1]{\setcounter{secnumdepth}{-1} \section{#1} \setcounter{secnumdepth}{2} \setcounter{subsection}{0} \setcounter{corollary}{0} \setcounter{definition}{0} \setcounter{theorem}{0}}
